<%@page import="bbs.BBSVo"%>
<%@page import="bbs.BBS"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%request.setCharacterEncoding("utf-8"); %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html >
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css">
	body {
	font-family: '나눔고딕';
	font-size: 14px;
	font-weight: bold;
	color: red;
	margin-top: 100px;
	background-image: url('../../images/main.jpg');
	background-size: 55% 57%;
	}
	.bw_btn{
		background-color: black;
		color: red;
		font-weight: bold;
		font-size: 15px;
	}
	.b_tb{
		background-color: black;
	}
	.bw_td{
		color: red;
		font-weight: bold;
		font-size: 20px;
	}
</style>
<script src="${pageContext.request.contextPath }/se2/js/HuskyEZCreator.js" type="text/javascript" charset="utf-8"></script>
<!-- 이미지 업로드 관련된 js파일 -->
<script src="${pageContext.request.contextPath }/se2/photo_uploader/plugin/hp_SE2M_AttachQuickPhoto.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
	function fnEdit(frm) {
		if(frm.mid.value == ""){
			alert("아이디를 입력해주세요!");
			frm.mid.focus();
			return false;
		}
		if(frm.pwd.value == ""){
			alert("암호를 입력해주세요!");
			frm.pwd.focus();
			return false;
		}
		if(frm.title.value == ""){
			alert("제목을 입력해주세요!");
			frm.title.focus();
			return false;
		}
		if(frm.pass.value != frm.pwd.value){
			alert("비밀번호가 일치 하지 않습니다!");
			frm.pwd.focus();
			return false;
		}
		var sHTML = oEditors.getById["textAreaContent"].getIR();
		frm.content.value=sHTML;
		frm.submit();
	}
</script>
</head>
<body>
	<jsp:useBean id="bv" class="bbs.BBSVo" />
	<jsp:setProperty property="*" name="bv"/>
	<%
		BBS bbs = new BBS();
		bbs.setBv(bv);
		BBSVo vo = bbs.view();
	%>
	<c:set var="vo" value="<%=vo %>"></c:set>
	<form action="${pageContext.request.contextPath }/homepage/bbs/BEResult.jsp" method="post" onsubmit="return fnEdit(this)">
		<input type="hidden" name="num" id="num" value="${vo.num }">
		<input type="hidden" name="pass" id="pass" value="${vo.pwd }">
		<div align="center" id="bw_div">
			<h1>글 수정</h1>
			<table class="b_tb" width="75%">
				<tr>
					<td class="bw_td">작성자</td>
					<td>
						<input type="text" name="mid" id="mid" value="${vo.mid }" readonly="readonly">
					</td>
					<td width="50px;"></td>
				</tr>
				<tr>
					<td class="bw_td">암호</td>
					<td>
						<input type="password" name="pwd" id="pwd">
					</td>
					<td width="50px;"></td>
				</tr>
				<tr>
					<td class="bw_td">제목</td>
					<td><input type="text" size="100" name="title" id="title" value="${vo.title }"></td>
				</tr>
				<tr>
					<td class="bw_td">내용</td>
					<td bgcolor="red">
						<textarea name="content" id="textAreaContent" rows="10" cols="100" style="width:100%; height:412px; min-width:610px; display:none;">${vo.sbContent.toString() }</textarea>
					</td>
				</tr>
			</table>
			<table width="75%" class="b_tb">
				<tr>
					<td align="right">
							<input type="submit" value="글수정" id="btnWrite" class="bw_btn">
						<input type="button" value="다시 작성" id="btnReset" class="bw_btn">
						<a href="javascript:onclick=history.back();">
							<input type="button" value="취소" id="btnCancel" class="bw_btn"></a>
						<a href="#">
							<input type="button" value="목록" id="btnList" class="bw_btn"> </a>
					</td>
					<td width="50px;"></td>
				</tr>
			</table>
			
		</div>
	</form>
	<script type="text/javascript">
	//스마트 에디터 붙이는 부분
		var oEditors = [];
		nhn.husky.EZCreator.createInIFrame({
		    oAppRef: oEditors,
		    elPlaceHolder: "textAreaContent",
		    sSkinURI: "${pageContext.request.contextPath }/se2/SmartEditor2Skin.html",
		    fCreator: "createSEditor2"
		});
		// textArea에 이미지 첨부
		function pasteHTML(filepath){
		    var sHTML = '<img src="${pageContext.request.contextPath }/se2/upload/'+filepath+'">';
		    oEditors.getById["textAreaContent"].exec("PASTE_HTML", [sHTML]); 
		}
	</script>
</body>
</html>